<include file="public@storage"/>
</head>
<body>
<div class="container body-content" style="margin-top:20px;width: 100%">
    <div class="panel panel-info" style="margin-bottom: 0.5rem">
        <div class="panel-heading">小车管理</div>

        <input type="hidden" id="storageUuid" value="{$storageInfo[0]['uuid']}">
        <input type="hidden" id="returnValue" value="{$history}">
        <div class="panel-body">
            <div class="row">
                <div class="col-sm-12">
                    <div id="toolbar" class="btn-group">
                        <button id="addSelf" class="btn btn-info" style="margin-left: 1rem; width: 10rem"
                                onclick="add()">添加小车
                        </button>
                    </div>
                    <table id="table"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    $(function () {
        init();
    });

    function init() {
        var url = "{:url('/storage/Car/getCar')}";
        var columns = [
            {
                title: '序号',
                width: 50,
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    return index + 1;
                }
            },
            {
                title: 'uuid',
                field: 'uuid',
                visible: false
            },
            {
                title: '小车号',
                field: 'car_id',
                align: "center",
                filter: {
                    type: 'input'
                }
            },
            {
                title: 'A类站位数',
                field: 'a_count',
                align: "center",
                filter: {
                    type: 'input'
                }
            },
            {
                title: 'B类站位数',
                field: 'b_count',
                align: "center",
                filter: {
                    type: 'input'
                }
            },
            {
                title: 'C类站位数',
                field: 'c_count',
                align: "center",
                filter: {
                    type: 'input'
                }
            },
            {
                title: '小车状态',
                field: 'name',
                align: "center",
                filter: {
                    type: 'input'
                }
            },
            {
                title: '操作',
                field: 'uuid',
                align: "center",
                valign: 'middle',
                formatter: function (value, row) {
                    return '<a onclick="deleteCar(this)" href="javascript:void(0);" data-uuid="' + row.uuid + '"> 删除</a>';
                }
            }
        ];
        initTable(url, columns, 'server', InitSubTable);
        setColumn();
    }


    InitSubTable = function (index, row, $detail) {
        var tableId = "cur_table_"+index;
        $detail.html('<table id="'+ tableId+ '"></table>').find('table');
        var url = '{:url("storage/Car/getCarDetail")}?carUuid=' + row.uuid;
        var column = [
            {
                title: '序号',
                width: 50,
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    return index + 1;
                }
            },
            {
                title: 'uuid',
                field: 'uuid',
                align: "center",
                visible: false
            },
            {
                title: '站位号',
                field: 'seat_code',
                align: "center",
            },
            {
                title: '料号',
                field: 'sub_materiel_id',
                align: "center",
            },
            {
                title: '条码',
                field: 'reel_id',
                align: "center",
            },
            {
                title: '数量',
                field: 'count',
                align: "center"
            },
            {
                title: '时间',
                field: 'time',
                align: "center",
            }

        ];
        initSubTable(tableId,url, column, 'client', true);
    };


    function add() {
        window.open("{:url('/storage/Car/add')}", '_self');
    }

    deleteCar = function (that) {
        var uuid = $(that).data('uuid');
        var param = {uuid: uuid};
        var url = "{:url('/storage/Car/deleteCar')}";
        reviseTable('是否删除小车', url, param);
    }

</script>
</html>